package unit4_1013.test3.manage;

import unit4_1013.test3.cars.Bus;
import unit4_1013.test3.cars.Car;
import unit4_1013.test3.cars.Vehicle;

public class VehicleRentBusiness {
	
	private Vehicle[] vs=new Vehicle[8];
	
	public void init() {
		vs[0]=new Car("京A83BT5", "奔驰", "E200L", 599);
		vs[1]=new Car("京C87239", "奔驰", "S350L", 1699);
		vs[2]=new Car("京N39	W20", "宝马", "525Li", 599);
		vs[3]=new Car("京P80K27", "宝马", "530Li", 699);
		vs[4]=new Bus("京C68U35", "金龙", 53, 700);
		vs[5]=new Bus("京C68U35", "金龙", 45, 550);
		vs[6]=new Bus("京C68U35", "考斯特", 22, 450);
		vs[7]=new Bus("京C68U35", "考斯特", 37, 600);
	}
	
	public Vehicle leaseOut(String brand,String model,int seat) {
		Vehicle vehicle=null;
		for(Vehicle v:vs) {
			if(v instanceof Car) {
				Car car=(Car) v;
				if(car.getBrand().equals(brand) && car.getModel().equals(model)) {
					vehicle=car;
					break;
				}				
			}else {
				Bus bus=(Bus) v;
				if(bus.getBrand().equals(brand) && bus.getSeatCount()==seat) {
					vehicle=bus;
					break;					
				}
			}
		}
		
		return vehicle;//返回一个汽车对象
	}
	
}
